package com.company;

/*
* 某系统的数字密码(大于e) 。比如1983，采用加密方式进行传输，
    规则如下:
    每位数加上5
    再对数字 用10求余，
    最后将所有数字反转，
    得到一串新数。
* */
public class Test4 {
    public static void main(String[] args) {
        int[] arr = decoArray(2026);

        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] + 5;
        }

        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] % 10;
        }
        for (int i = 0, j = arr.length - 1; i < j; i++, j--) {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        int number = 0;
        for (int i = 0; i < arr.length; i++) {

            number = number * 10 + arr[i];
        }

        System.out.println(number);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    public static int[] decoArray(int number) {

        int temp = number;

        int count = 0;
        while (number != 0) {
            number = number / 10;
            count++;
        }

        int[] arr = new int[count];

        int index = arr.length - 1;
        while (temp != 0) {
            int ge = temp % 10;
            temp = temp / 10;
            arr[index] = ge;
            index--;
        }

        int B = 0;
        for (int i = 0; i < arr.length; i++) {
            B = B * 10 + arr[i];
        }

        return arr;

    }
}
